<?php

/**
 * 首页模块
 * @author lan7
 * @copyright lan7.net
 * @version 2.0
 */

if(!defined('IN_ORA')) {
	exit('Access Denied');
}
class index extends mod {

	/**
	 * 构造方法
	 *
	 */
	function __construct(){
		/** 当前模块类存在构造方法的时候, 须执行父类的构造方法 **/
		parent::__construct();
		$active[get_urlStr()] = ' class="cur" ';
		$this->assign('active',$active);
	}
	/**
	 * 默认首页
	 *
	 * @return index
	 */
	function index(){
		/** 设置缓存当前模块数据( 模板/ 数据 ) **/
		if(!$this->isCached("index-index")){
			/** 站点信息 **/
			$this->assign('sinfo',$GLOBALS['db']->getOne('select * from '.tn('info').' order by Id asc limit 1'));
			/** 导航信息 **/
			$this->assign('navs',$GLOBALS['db']->getAll('select * from '.tn('nav').' order by nav_sort desc'));
			/** 动态信息 **/
			$this->assign('arts',$this->db->getAll("select Id,title,dateline from ".tn("article")." where status >=1 order by Id desc limit 6"));
			/** 新品展示 **/
			$sql = 'select op.Id,op.pro_price,op.vod_id,op.pro_name,op.pro_keywords,op.pro_pic,oc.cat_name,op.cat_id from '.tn("product").' op left join '.tn("cat").' oc on op.cat_id = oc.Id where op.pro_status > 0  order by op.Id desc limit 6';
			$this->assign('new_pros',$GLOBALS['db']->getAll($sql));
			/** 当前位置 **/
			$local = array();
			$local[] = array('url'=>parse_uri('index-index'),'text'=>'首页');
			$this->assign('local',$local);
		}
		$this->display("index.html");
	}

	/**
	 * 站点订阅
	 *
	 */
	function feed(){
		if(!$this->isCached("index-feed")){
			/** 站点信息 **/
			$this->assign('sinfo',$GLOBALS['db']->getOne('select * from '.tn('info').' order by Id asc limit 1'));
			$sql = "select op.Id,op.cat_id,op.pro_name,op.pro_dateline,oc.cat_name from ".tn('product');
			$sql.= " op left join ".tn('cat')." oc on op.cat_id = oc.Id  order by Id desc limit 30";
			$this->assign('pros',$GLOBALS['db']->getAll($sql));
			$this->assign("now",time());
		}
		$this->display("feed.html");
	}
}
?>